<?php

namespace Vavilen\FirstBundle\DataFixtures\ORM;

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Vavilen\FirstBundle\Entity\Category;

class LoadCategoryData extends AbstractFixture  implements OrderedFixtureInterface, FixtureInterface
{

    public function load(ObjectManager $manager)
    {
        $category1 = new Category();
        $category1->setCategoryName('Новости');
        $category1->setUrl('news');
        $manager->persist($category1);
        $this->addReference('news', $category1);

        $category2 = new Category();
        $category2->setCategoryName('Булки');
        $category2->setUrl('bulk');
        $manager->persist($category2);
        $this->addReference('bulk', $category2);

        $category3 = new Category();
        $category3->setCategoryName('Картон');
        $category3->setUrl('karton');
        $manager->persist($category3);
        $this->addReference('karton', $category3);

        $manager->flush();
    }

    public function getOrder()
    {
        return 1;
    }
}